package controller

import (
	"encoding/json"
	"fmt"
	"io"
	"net/http"

	"gitee.com/shuwenhe/shuwen/encoding/json/encode.go/Marshal2/model"
	"gitee.com/shuwenhe/shuwen/encoding/json/encode.go/Marshal2/service"
)

func GetMovie(w http.ResponseWriter, r *http.Request) {
	actors, _ := service.GetActors()
	movie := model.Movie{
		Title:  "三个火枪手",
		Year:   2021,
		Price:  59,
		Actors: actors,
	}
	movieString, err := json.Marshal(movie)
	if err != nil {
		fmt.Println("json marshal error :", err)
		return
	}
	fmt.Printf("movie:%v\n", movie)
	io.WriteString(w, string(movieString))
}
